Summary 3

Back

Timothy J. Neeb

Prof. Blake Johnson

Anatomy of a CSS Rule

A CSS Rulew is made up of two parets, the selector which says which tag the rule is selecting, and the declration which says what happens when that rule is applied (the text is displayed in red). The declaration is comprised of two seperate elements. A property elemtent which states what is to be affected and a value which states what the property is set to (red).

Writing CSS Rules

Multiple Declarations can be Contained within a rule

Each declaration ends with a semicolon to separate it from the next. The last semicolon before the closing curly brakcet is potional, howver it is best to add it so that you can tack on extra declarations without having to remember.

Multiple selectors can be grouped

If you wanted to make text for tags h1 through h6 to a certain color and be bold you could go through individually and change the color and the font weight. There is a way to avoid this repition by grouping selectors in a single rule as shown below:

h1, h2, h3, h4, h5, h6 {color:blue; font-weigh:bold;}

If you choose to do it this way however you must be sure and put commas inbetween each selector

Introducing ID's

ID's are written very similarly to classes just that you use '#' symbol to show that theyre in CSS instead of the class's. The main difference between ID's and Classes is that ID's are more powerful than class. According to the rules of XHTML, only a single instance of particular ID (such as id="mainmenu") can be in a page, but class (such as class="strongparagraph") can appear many times